import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
// import whoami from '@feidao/web/atom/browser/msg/whoami';
import s_get from '@dfeidao/atom-web/storage/get';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';

import set from '@dfeidao/atom-web/local/set';
import P02 from './P02';
import P04 from './P04';
// import P05 from './P05';





export default async function a005(fd: IFeidaoAiBrowserComponent, args: { p_id: string, client_style: string, formid: string, flag: number, id: string, client_point_id: string }) {
	//  调用事件
	fd.data.node.classList.remove('display-n');
	const f = fd.data.node.querySelector<HTMLFormElement>('#pub_menu_form');
	f.menu_name.value = '';
	f.formname.value = '';
	f.priority.value = 0;
	f.description.value = '';
	f.icon.value = '';
	f.background.value = '';

	fd.data.node.querySelector<HTMLSpanElement>('#client_style').innerHTML = args.client_style;
	set(fd, 'client_point_id', args.client_point_id);
	// set(fd, 'formid', args.formid);/
	if (args.flag === 1) {
		// 同级
		set(fd, 'parent_no', args.p_id);
	} else {
		// 子级
		set(fd, 'parent_no', args.id);
	}
	// const user = await whoami(get_user_info);

	const productid = await s_get('productid');
	const res1 = await nodejs<{ dataArray: string[] }>('menu/zj-000002/s001', { productid });
	render(fd, res1, P02, 'P02', 'inner');
	const systemid = fd.data.node.querySelector<HTMLSelectElement>('#systemid').value;
	const res2 = await nodejs<{ dataArray: string[] }>('menu/zj-000002/s002', { productid, systemid });
	render(fd, res2, P04, 'P04', 'inner');
	// const res3 = await nodejs<{ dataArray: string[] }>('menu/zj-000001/s005', { productid });
	// render(fd, res3, P05, 'P05', 'inner');
}
